package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;

public class CheckOutMenuState implements State {
    private Library library;

    public CheckOutMenuState(Library library) {

        this.library = library;
    }

    @Override
    public State next(BufferedReader reader) {
        String userInput;
        int bookChoice;
        try {
            userInput = reader.readLine();
            bookChoice = Integer.parseInt(userInput) - 1;
            return new CheckOutState(library, bookChoice);
        } catch (IOException e) {
            e.printStackTrace();
            return new ExitState();
        } catch (Exception e){
            return this;
        }

    }

    @Override
    public String getMessage() {
        return library.toStringBooks() + "\n\nPlease Select a Book:\n";  //To change body of implemented methods use File | Settings | File Templates.
    }
}
